/*-------------------------------------------------------------------------
 - Copyright (c) 2024-2025 [XD-AMCC TEAM]
 - [XD-AMCC] is licensed under Mulan PSL v2.
 - You can use this software according to the terms and conditions of the Mulan PSL v2.
 - You may obtain a copy of Mulan PSL v2 at:
 -          http://license.coscl.org.cn/MulanPSL2
 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES
 - OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 - TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 - See the Mulan PSL v2 for more details.
 ------------------------------------------------------------------------*/


/**
 * @file
 * @brief Interface of date and time.
 *
 * @author  WXQ#XDU
 * @date    2024.11
 */

#pragma once

#ifndef AMCC_TIME_H
#define AMCC_TIME_H

#include <time.h>

#include "amcc_config.h"

AMCC_DECL_BEGIN


typedef struct amcc_time {
    struct tm   tm;        //!< fields of time
    time_t      tv_sec;    //!< seconds from EPOCH
    int         tv_msec;   //!< milliseconds in a second
} t_time;

/**
 * @brief Get current system time in the local time zone.
 * @return Return a structure containing a calendar date
 *         and time broken down into its components.
 */
t_time  amcc_get_time();

/**
 * @brief Get a string representing the 'pTime' time
 *        for the local time zone.
 * @param pTime pointer to a t_time object
 * @return Return a string like "2024-11-30 09:12:23.123".
 */
const char * amcc_get_timestring(t_time * pTime);

AMCC_DECL_END

#endif // #ifndef AMCC_TIME_H
